\ProvidesPackage{beamerthemeUIC}
\RequirePackage{ifthen}
\RequirePackage{beamerposter}

\mode<presentation>

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set up theme options

\DeclareOption{color}{
	\colorlet{TDK}{blue}
	\renewcommand{\department}{DEPARTMENT OF MICRO- AND NANOELECTRONICS}
	\renewcommand{\faculty}{FACULTY OF ELECTRONICS}
	\renewcommand{\logo}{images/leti_logo_bw.pdf}
}



\DeclareOption{twocolumn}{
	\renewcommand{\insertcolumnwidth}{0.470\paperwidth}
}

\DeclareOption{threecolumn}{
	\renewcommand{\insertcolumnwidth}{0.294\paperwidth}
}

\DeclareOption{fourcolumn}{
	\renewcommand{\insertcolumnwidth}{0.22\paperwidth}
}

\selectcolormodel{rgb}
\definecolor{grey55}{RGB}{100, 100, 100}
\definecolor{grey}{RGB}{230, 230, 230}
%\definecolor{blue}{RGB}{58, 111, 196}
\definecolor{blue}{RGB}{41, 113, 174}
\definecolor{yellow}{RGB}{233, 214, 72}
\definecolor{lightblue}{RGB}{195, 236, 255}
% Program in DST with different banner 
\definecolor{AppliedPsychology}{RGB}{255,204,204}
\definecolor{ComputerScienceTechnology}{RGB}{204,236, 255}
\definecolor{DataScience}{RGB}{51, 204, 204}
\definecolor{FinancialMathematics}{RGB}{204, 51, 0}
\definecolor{FoodScience}{RGB}{255, 255, 0}
\definecolor{EnvironemntalScience}{RGB}{0, 204, 0}
\definecolor{Statistics}{RGB}{179, 162, 199}


%\newcommand{\logo}{img/logo.png}
\newcommand{\department}{\mbox{}}
\newcommand{\faculty}{\mbox{}}
\colorlet{TDK}{black}

\newcommand{\titlestart}[1]{\newcommand{\inserttitlestart}{#1}}
\newcommand{\author}[1]{\newcommand{\insertauthor}{#1}}

\newcommand{\insertleftcorner}{}
\newcommand{\leftcorner}[1]{\renewcommand{\insertleftcorner}{#1}}

\newcommand{\inserttitlesize}{\veryHuge}
\newcommand{\titlesize}[1]{\renewcommand{\inserttitlesize}{#1}}

\title{\inserttitlestart~\insertauthor}

% Boolean which tells whether there is an open 'block' environment
\newboolean{inblock}
\setboolean{inblock}{false}

\newcommand{\insertcolumnwidth}{0.294\paperwidth}

% Command to start a new column, ending open block if one exists
\newcommand{\newcolumn}{\ifthenelse{\boolean{inblock}}{
            \end{block}}{}\column{0.005\paperwidth}\column{\insertcolumnwidth}}

% Set up all environments so the user doesn't have to
\newenvironment{poster}
{
\begin{frame}[t, fragile, environment=poster]
\begin{columns}[T]
    \column{0.025\paperwidth}
}
{
\ifthenelse{\boolean{inblock}}{\end{block}}{}
\column{0.05\paperwidth}\end{columns} 
\end{frame} 
}

% Command to start a new block, ending open block if one exists
\renewcommand{\section}[1]{%
\ifthenelse{\boolean{inblock}}{\end{block}}{}
\setboolean{inblock}{true}
\begin{block}{#1}
}

\renewcommand{\subsection}[1]{{\raggedright\color{TDK}\LARGE#1\vskip-10pt}}
\renewcommand{\caption}[1]{{\vspace{-1em}\color{TDK}\\\large#1\\}}


% Process options given to the package
\ProcessOptions\relax







%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% headline colors and fonts
\setbeamercolor{headline}{fg=black,bg=white}
\setbeamercolor{title coloured}{fg=TDK}
\setbeamercolor{title grey}{fg=yellow,bg=white}
\setbeamercolor{institute in footline}{fg=TDK}

% footline colors and fonts
\setbeamercolor{footline}{fg=black,bg=white}
\setbeamerfont{footline}{size=\Large}

% lines
%\setbeamercolor{upper separation line head}{fg=ta2orange}
\setbeamercolor{separation line}{bg=black}

% poster background, body colors, and fontss
\setbeamercolor*{normal text}{fg=black,bg=white}

% block environment
\setbeamercolor*{block body}{bg=white,fg=black}
\setbeamerfont{block body}{size=\large,fg=black}
\setbeamercolor*{block title}{fg=TDK,bg=white}
\setbeamerfont{block title}{size=\LARGE}

\setbeamercolor{block title alerted}{fg=blue,bg=lightblue}
\setbeamercolor{block body alerted}{fg=black,bg=lightblue}
\setbeamerfont{block body alerted}{size=\large}
\setbeamercolor{alerted text}{fg=TDK}

\setbeamercolor{faculty title}{fg=grey55,bg=white}

\setbeamertemplate{itemize items}[circle]
\setbeamercolor{itemize item}{fg=TDK,bg=white}
\setbeamercolor{enumerate item}{fg=TDK,bg=white}
\setbeamercolor{description item}{fg=TDK,bg=white}
\setlength{\leftmargini}{20pt} % left margin in itemsize

\setbeamercolor{caption name}{fg=TDK,bg=white}
\setbeamertemplate{caption}[numbered]

\setbeamertemplate{navigation symbols}{}  % no navigation on a poster

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Setting up a text block
\setbeamertemplate{block begin}{
	\vskip3ex
	\begin{beamercolorbox}[ht=0ex,dp=1ex,center,rounded=false,shadow=false,
                           leftskip=0ex,rightskip=0pt plus 4em, 
                           colsep*=1.75ex]{block title}
		\usebeamerfont*{block title}{\bfseries{\insertblocktitle}}
%		\usebeamerfont*{block title}\MakeUppercase{\insertblocktitle}
	\end{beamercolorbox}
            % change line spacing
            \renewcommand{\baselinestretch}{0.85} 
	{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}
	\usebeamerfont{block body}
	\begin{beamercolorbox}[rounded=false,shadow=false,leftskip=0cm,
        rightskip=0pt plus 4em,colsep*=.75ex,sep=0ex,vmode]{block body}
	\setlength{\parskip}{1.5ex}
	\ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}
}

\setbeamertemplate{block end}{
  \end{beamercolorbox}
}

% Spacing before and after section titles
\let\origsection\section
\renewcommand\section{\@ifstar{\starsection}{\nostarsection}}

\newcommand\nostarsection[1]
{\sectionprelude\origsection{#1}\sectionpostlude}

\newcommand\starsection[1]
{\sectionprelude\origsection*{#1}\sectionpostlude}

\newcommand\sectionprelude{%
    \vspace{1.55em}
}

\newcommand\sectionpostlude{%
    \vspace{-1.55em}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is the title part
\setbeamertemplate{headline}{%
\leavevmode%

\begin{beamercolorbox}[wd=\paperwidth]{frame title}
\begin{columns}
	\begin{column}[b]{.01\paperwidth} % filler
	\end{column}

	% Typeset the title part differently based on orientation,
    % this is a slightly
	% quick hack, needs refinement
	\if@beamerposter@portrait

	% TITLE
	\begin{column}[b]{0.95\paperwidth}
		\vskip10ex
		\includegraphics[width=0.125\paperwidth]{\logo}\\
%		\vskip3ex
		\raggedright
        \setlength\lineskip{12pt}
		\usebeamercolor{title coloured}{
            \color{black}\inserttitlesize{\inserttitlestart}}\\
		\vspace{2ex}
		\usebeamercolor{title grey}{
            \color{black}\inserttitlesize{\insertauthor}}

	% AUTHOR LIST        
		\vskip5ex
        \raggedright
		\usebeamercolor{author in headline}{\color{black}\Large{\insertinstitute}}
        \vspace{2ex}           
	\end{column}
	

%    \begin{column}[b]{0.12\paperwidth}
%        \raggedleft
%        \Large{ St. Petersburg Electrotechnical University}
%        \vskip
%        \vspace{2ex}
%    \end{column}

%	\begin{column}[b]{0.15\paperwidth}
%        \centering
%        \includegraphics[width=0.9\columnwidth]{\logo}\\
%        \vspace{5ex}
%    \end{column}
    
       
	% If orientation is landscape, do this:
	\else
%
%	% TITLE landscape
%	\begin{column}[b]{0.13\paperwidth}
%		\vskip5ex
%		\includegraphics[width=0.1\paperwidth]{\logo}\\
%	\end{column}
%
%	\begin{column}[b]{0.47\paperwidth}
%		\raggedright
%		\usebeamercolor{title coloured}{
%            \color{fg}\inserttitlesize{\MakeUppercase{\inserttitlestart}}}\\
%		\vspace{2ex}
%		\usebeamercolor{title grey}{
%            \color{fg}\inserttitlesize{\MakeUppercase{\inserttitleend}}}
%	\end{column}
%
%	% AUTHOR LIST
%	\begin{column}[b]{0.3\paperwidth}
%		\raggedright
%		\usebeamercolor{author in headline}{
%            \color{fg}\normalsize{\insertauthor}}
%		\vskip5ex
%		\usebeamercolor{author in headline}{
%            \color{fg}\footnotesize{\insertinstitute}}
%	\end{column}
	\fi

	\begin{column}{.01\paperwidth} % filler
	\end{column}
\end{columns}
\end{beamercolorbox}

%\vskip3ex
%  \begin{beamercolorbox}[wd=\paperwidth]{line}
%\hskip0.05\paperwidth\rule{0.90\paperwidth}{2pt}
%  \end{beamercolorbox}
%\vskip5ex
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{footline}{  
  \leavevmode%
  \begin{beamercolorbox}[ht=7ex, wd=\paperwidth]{footline}
      \begin{columns}
          \begin{column}[c]{.01\paperwidth} % filler
          \end{column}
          % LOGO
          \begin{column}[c]{0.06\paperwidth}
               %\includegraphics[width=5\columnwidth]{\logo}
               \vspace{1.5ex}
          \end{column}
          % Name
          \begin{column}[c]{0.3\paperwidth}
              \raggedright
              %\color{black}\Large{United International College}
              \vspace{1ex} 
          \end{column}
          
          \begin{column}[c]{.5\paperwidth} % filler
          \end{column}      
          
          
          \begin{column}[c]{.01\paperwidth} % filler
          \end{column}          
      \end{columns}

  \end{beamercolorbox}
  }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<all>


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Local Variables: 
%%% mode: latex
%%% TeX-PDF-mode: t
%%% TeX-master: "poster"
%%% End: 